package com.bw.purchase.controller;

import com.bw.purchase.service.TbHouseGroupBuyingService;
import com.bw.result.ResultVo;
import com.bw.vo.IdVo;
import com.bw.vo.TbHouseGroupBuyingSearchVo;
import com.bw.vo.TbHouseGroupBuyingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: search-house
 * @ClassName GroupBuyingManagerController
 * @description:
 * @author:
 * @create: 2023-11-11 10:22
 * @Version 1.0
 **/
@RestController
@RequestMapping("/purchase")
@Api(tags = "团购管理")
@Slf4j
public class TbGroupBuyingManagerController {


    @Autowired
    private TbHouseGroupBuyingService tbHouseGroupBuyingService;


    /** @Author 李博帅
     * @Description //TODO 团购添加
     * @Date 10:30 2023/11/11
     * @param tbHouseGroupBuyingVo
     * @return com.bw.result.ResultVo
     **/
    @ApiOperation("团购添加")
    @PostMapping("/add")
    public ResultVo add(@RequestBody TbHouseGroupBuyingVo tbHouseGroupBuyingVo){
        return tbHouseGroupBuyingService.add(tbHouseGroupBuyingVo);
    }


    /** @Author 李博帅
     * @Description //TODO 通过主键id删除 逻辑
     * @Date 10:35 2023/11/11
     * @param idVo
     * @return com.bw.result.ResultVo
     **/
    @ApiOperation("团购删除")
    @PostMapping("/del")
    public ResultVo del(@RequestBody IdVo idVo){
        return tbHouseGroupBuyingService.del(idVo);
    }



    /** @Author 李博帅
     * @Description //TODO 团购修改
     * @Date 10:40 2023/11/11
     * @param tbHouseGroupBuyingVo
     * @return com.bw.result.ResultVo
     **/
    @ApiOperation("团购修改")
    @PostMapping("/update")
    public ResultVo update(@RequestBody TbHouseGroupBuyingVo tbHouseGroupBuyingVo){
        return tbHouseGroupBuyingService.updateByVo(tbHouseGroupBuyingVo);
    }


    /** @Author 李博帅
     * @Description //TODO  列表+模糊查询+分页
     * @Date 10:43 2023/11/11
     * @param tbHouseGroupBuyingSearchVo
     * @return com.bw.result.ResultVo
     **/
    @ApiOperation("团购列表")
    @PostMapping("/list")
    public ResultVo list(@RequestBody TbHouseGroupBuyingSearchVo tbHouseGroupBuyingSearchVo){
        return tbHouseGroupBuyingService.getList(tbHouseGroupBuyingSearchVo);
    }
}
